package com.epam.javalab.giorgadze.task2.entity;

import java.util.ArrayList;
import java.util.List;

/**
 */
public class Text implements SentencePart<Paragraph> {
    private List<Paragraph> paragraphList = new ArrayList<Paragraph>();

    public List<Paragraph> getSentenceList() {
        return paragraphList;
    }

    public void setSentenceList(List<Paragraph> sentenceList) {
        this.paragraphList = sentenceList;
    }

    public Text(List<Paragraph> paragraphList) {
        this.paragraphList = paragraphList;
    }

    public Text() {
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Text text = (Text) o;

        if (paragraphList != null ? !paragraphList.equals(text.paragraphList) : text.paragraphList != null)
            return false;

        return true;
    }

    @Override
    public int hashCode() {
        return paragraphList != null ? paragraphList.hashCode() : 0;
    }

    @Override
    public String toString() {
        return "Text consists of the following paragraphs: " + paragraphList;
    }

    @Override
    public void add(Paragraph element) {
        paragraphList.add(element);
    }

    @Override
    public void remove(Paragraph element) {
        paragraphList.remove(element);
    }
}
